package cn.itcast.hotel.config;



import cn.itcast.hotel.constants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {
    @Bean
    public Queue queueIndex(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    public Queue queueDelete(){
        return new Queue(MqConstants.HOTEL_DELETE_QUEUE);
    }

    @Bean
    public TopicExchange exchange(){
        return new TopicExchange(MqConstants.HOTEL_EXCHANGE);
    }

    @Bean
    public Binding bindIndex(Queue queueIndex, TopicExchange exchange){
        return BindingBuilder.bind(queueIndex).to(exchange).with(MqConstants.HOTEL_INSERT_KEY);
    }
    @Bean
    public Binding bindDelete(Queue queueDelete, TopicExchange exchange){
        return BindingBuilder.bind(queueDelete).to(exchange).with(MqConstants.HOTEL_DELETE_KEY);
    }
}
